package plug.bookmarks;
import java.sql.*;

import com.uujava.minibox.config.Config;
import com.uujava.tools.Str;
/**
 * 功能：得到数据库连接
 * @author k 2013年8月12日 14:51:41
 *
 */
public final class ConnDB {
	private Connection ct = null;

	public Connection getConn() {

	 	final String sourceURL = Str.bufferAppend("jdbc:h2:",Config.DATABASE_PATH).toString();// H2 database
		final String user = "sa";
		final String key = "";

		try {
			Class.forName("org.h2.Driver");
			try {// 2得到连接
				ct = DriverManager.getConnection(sourceURL, user, key);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				print("连接数据库失败");
				e.printStackTrace();
			}
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			print("加载数据库驱动失败");
			e.printStackTrace();
		}// H2 Driver

		return ct;
	}
	private void print(String str){
		System.out.print("ConnDB类"+str);
	}
}
